package qgs.zisu.javaconcurrency.javaconcurrency.chapter2;

/**
 * @Author: 蔡翔
 * @Date: 2019/9/6 8:42
 * @Version 1.0
 * 多个线程中消费同一个Runnable
 */
public class Bank2 {
    public static void main(String[] args) {
        //业务数据的实例只有一个。这里的话线程和 业务就分开了。
        // Runnable接口的作用就是：将可执行的逻辑单元，和线程控制 分离开来。。这也是面向对象思想一个比较好的体现。
        final TicketWindowRunnable ticketWindowRunnable = new TicketWindowRunnable();

        // 定义 1-4 个线程
        Thread windowThread1 = new Thread(ticketWindowRunnable,"一号窗口");
        Thread windowThread2 = new Thread(ticketWindowRunnable,"二号窗口");
        Thread windowThread3 = new Thread(ticketWindowRunnable,"三号窗口");
        Thread windowThread4 = new Thread(ticketWindowRunnable,"四号窗口");

        windowThread1.start();
        windowThread2.start();
        windowThread3.start();
        windowThread4.start();
    }
}
